import { createApp } from 'vue';
import App from './App.vue';

import ElementPlus from 'element-plus';
import 'dayjs/locale/zh-cn';
import locale from 'element-plus/lib/locale/lang/zh-cn';
import 'element-plus/dist/index.css';
import '@assets/global.less';

import * as echarts from 'echarts'

import ZeesuuService from '@zeesuu/service';
import ZeesuuSearchList from '@comp/searchlist';
import ZeesuuSelect from '@comp/select';
import CustomSelectData from '@config/CustomSelectData';

import API from '@config/API.js';
import store from '@store/index.js';

import router from './router/index.js';
import axios from './utils/axios.js';

// 权限
import permission from '@/utils/permission';

/**
 * Init App
 */
const app = createApp(App);

/**
 * Use Router Config
 */
app.use(router);

/**
 * Use Element Plus
 */
app.use(ElementPlus, { locale, size: 'small' });

/**
 * Plug Service
 */
app.use(ZeesuuService, {
  $http: axios,
  apis: API,
  debug: process.env.NODE_ENV === 'development',
});

app.use(ZeesuuSearchList);
app.use(ZeesuuSelect, {
  api: {
    // categorySl: { url: '/dict/categories' },
    // levelSl: { url: '/dict/hardlevels' },
    // jumpSl: { url: '/dict/jumpkinds' },
  },
  custom: CustomSelectData,
});

// 全局挂载请求头
app.config.globalProperties.JSON_HEADER = {
  headers: {
    'Content-Type': 'application/json',
  }
}

// 引入echarts
app.config.globalProperties.$echarts = echarts

/**
 * Plug Login
 */
app.use(store);

/**
 * 权限
 */
app.use(permission);

/**
 * Mount to Root Node
 */
app.mount('#app');
